#ifndef HIDABLETABWIDGET_H
#define HIDABLETABWIDGET_H

#include <QTabWidget>
#include <QTabBar>
#include <QWidget>
#include <QMouseEvent>


class TabWidget : public QTabWidget {

    public:

		TabWidget(QWidget *parent = 0) : QTabWidget(parent) {
        }

        void showTabBar(bool show) {
            tabBar()->setVisible(show);
        }

    protected:

        void tabInserted(int index) {
            QTabWidget::tabInserted(index);
            if(count() == 1) {
                showTabBar(false);
            } else {
                showTabBar(true);
            }
        }

        void tabRemoved(int index) {
            QTabWidget::tabInserted(index);
            if(count() == 1) {
                showTabBar(false);
            } else {
                showTabBar(true);
            }
        }

};


#endif // HIDABLETABWIDGET_H
